#include<bits/stdc++.h>
#define int long long
#define N 100005
using namespace std;

int n, rt, A, B;
vector<int>p[N], G[N], f[N][2]; //0:A 1:B
int Fa[N];
unordered_map<int, int>r[N];
void Go(int x, int fa) {
	Fa[x] = fa;
	f[x][0].push_back(0); f[x][1].push_back(0);
	int cnt = 0;
	for(auto y : p[x]) {
		if(y == fa) continue;
		//cout << x << " -> " << y << endl;
		G[x].push_back(y);
		f[x][0].push_back(0); f[x][1].push_back(0);
		cnt++;
		r[x][y] = cnt;
		Go(y, x);
	}
}

vector<int>z;
void ljm(int x, int dep, int v, int o) {
	if(o || dep == v) z.push_back(x);
	if(dep == v) return;
	for(auto y : G[x]) ljm(y, dep + 1, v, o);
}
void Get(int x, int Len, int No, int o) {
	z.clear();
	if(o) z.push_back(x);
	if(Len == 1) return;
	for(int i = 0; i < G[x].size(); i++) {
		if(i + 1 == No) continue;
		if(Len >= 2) ljm(G[x][i], 2, Len, o);
		if(o) z.push_back(G[x][i]);
	}
}


int dfs(int x, int No, int opt) {
	if(f[x][opt][No]) return f[x][opt][No];
	
	//cout << x << " " << No << " " << opt << endl;
	int res = 0;
	if(opt == 0) {
		Get(x, A, No, 0);
		if(z.size()) {
			for(auto now : z) {
				//cout << x << " " << No << " " << opt << " -> " << now << " " << 0 << " " << 1 << endl;
				res = max(res, dfs(now, 0, 1));
			}	
		}
		else {
			res = 1e9;
			Get(x, B, 0, 1);
			for(auto h : z) res = min(res, h); 
		}
	}
	else {
		res = 1e9;
		Get(x, B, 0, 1);
		for(auto h : z) res = min(res, dfs(h, 0, 0));
		int now = x;
		for(int i = 1; i <= B; i++) {
			if(Fa[x] == 0) break;
			int no = r[Fa[x]][x];
			x = Fa[x];
			//cout << x << " " << No << " " << opt << " -> " << x << " " << no << " " << 0 << endl;
			res = min(res, dfs(x, no, 0));
		}
	}
	//printf("f[%lld][%lld][%lld] = %lld\n", x, opt, No, res);
	return f[x][opt][No] = res; 
}
signed main() {
	freopen("nim.in", "r", stdin);
	freopen("nim.out", "w", stdout);
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);

	cin >> n >> rt >> A >> B; A++; B++;
	if(A <= B) {
		cout << 1;
		return 0;
	}
	for(int i = 1, u, v; i < n; i++) {
		cin >> u >> v;
		p[u].push_back(v);
		p[v].push_back(u);
	}
	Go(rt, 0);
	cout << dfs(rt, 0, 0);
	return 0;
}

/*
9 6 2 1
1 3
1 6
2 4
2 5
2 7
3 9
4 6
4 8

*/
